<template>
    <div id="jnz" class="container-fluid padding">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>该技能组能够实现配置打电话时坐席接电话方式</legend>
            <el-form :model="saveDatas" ref="saveDatas" label-width="80px" class="padding">
                <el-form-item label="响铃方式" prop="strategySelect">
                    <el-select v-model="saveDatas.strategySelect" style="width: 500px;">
                        <el-option v-for="item in strategys" :key="item.id" :value="item.key" :label="item.value">{{item.value}}</el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="">
                    <el-button type="primary" @click="submitData()">保存</el-button>
                    <el-button @click="resetForm('saveDatas')">重置</el-button>
                </el-form-item>
            </el-form>
        </fieldset>
    </div>
</template>
<script>
    export default {
        name: "fpfs",
        beforeCreate: function(){
            this.$nextTick(function () {
                this.$post('cti-manager-config/get-config',{//这里是发送给后台的数据
                    type:"callcenter_strategy"//表示是查询呼叫中心的策略
                })
                    .then((response) => {
                        let res = response.data;//拿到的后台的结果
                        this.saveDatas.strategySelect = res[0].en_name;
                    }).catch((response) => {
                    consoleLog(response)
                });
            });
        },
        data() {
            return {
                saveDatas:{
                    strategySelect:"",
                },
                strategys:
                    [
                        {key:"ring-all",value:"选择所有坐席，即让所有坐席振铃，那个先接就选择哪个。"},
                        {key:"long-idel-agent",value:"选择空闲时间最长的坐席。"},
                        {key:"round-robin",value:"轮询。"},
                        {key:"top-down",value:"按固定的顺序选择。"},
                        {key:"agent-with-least-talk-time",value:"总是选择通话时间最短的坐席。"},
                        {key:"agent-with-fewest-calls",value:"总是选择接电话次数最少的坐席。"},
                        {key:"sequentially-by-agent-order",value:"根据梯队和顺序选择。"},
                        {key:"random",value:"随机选择。"},
                    ],
            }
        },
        methods: {
            submitData: function () {//提交数据
                this.$post('cti-manager-config/update-config',{//这里是发送给后台的数据
                    callcenter_strategy:this.saveDatas.strategySelect,
                }).then((response) => {
                    if (response.data){
                        this.$message({message:"更新成功！",type:"success"})
                    }
                }).catch((response) => {
                    consoleLog(response)
                });
            }
        }
    }
</script>